package esmp.bootstrap.bean;

import common.utils.NetUtils;
import mybatis.generator.support.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ServerEnvironment implements InitializingBean {
    @Value("${spring.application.name:}")
    private String serverId;

    @Override
    public void afterPropertiesSet() throws Exception {
        if (StringUtils.isEmpty(serverId)) {
            serverId = NetUtils.getLocalHost();
        }
    }

    public String getServerId() {
        return serverId;
    }

    public void setServerId(String serverId) {
        this.serverId = serverId;
    }
}
